package it.xiuxian.dagongyuzhou.presenter


import com.lzy.okgo.OkGo
import it.xiuxian.dagongyuzhou.MainActivity
import it.xiuxian.dagongyuzhou.VersionBean

import it.xiuxian.lib.base.BaseBean
import it.xiuxian.lib.base.BasePresenter
import it.xiuxian.lib.base.ILoadBind
import it.xiuxian.lib.bean.NoticeBean
import it.xiuxian.lib.http.CallBackOption
import it.xiuxian.lib.http.HttpConfig
import it.xiuxian.lib.utils.EncodeUtils

import org.json.JSONObject

class MainActivityPresenter:BasePresenter<MainActivity>(){
    fun updateVersion(qudaoid:String){
        var json1 = JSONObject()
        json1.put("qudaoid",qudaoid)
        OkGo.post<BaseBean<VersionBean>>(HttpConfig.BASE_URL+"/appversion/list")
            .params("encrypt", EncodeUtils.encodeAES(json1.toString()))
            .execute(object : CallBackOption<BaseBean<VersionBean>>() {}.loadBind(mView as MainActivity).execute(
                object : ILoadBind<BaseBean<VersionBean>> {
                    override fun excute(bean: BaseBean<VersionBean>) {
                        if(bean.code==0){
                          //  ToastUtil.showShort(bean.msg)

                            (mView as MainActivity).getdata(bean.data)

                        }
                    }
                }
            ))

    }
    fun getNotice(){
        OkGo.post<BaseBean<NoticeBean>>(HttpConfig.BASE_URL+"/appnotice/newNotice")
            .execute(object : CallBackOption<BaseBean<NoticeBean>>() {}.loadBind(mView as MainActivity).execute(
                object : ILoadBind<BaseBean<NoticeBean>> {
                    override fun excute(bean: BaseBean<NoticeBean>) {
                        if(bean.code==0){
                          //  ToastUtil.showShort(bean.msg)
                            (mView as MainActivity).getNotice(bean.data)

                        }
                    }
                }
            ))

    }
}